

#====================================================================
#
#		COMMON HTML FRAGMENTS
#
#====================================================================


#--------------------------------------------------------------------
Function Get-HtmlHeader
{
	param
	(
		  [psobject]	$WebRequest			= $( throw "WebRequest is a required parameter." )
		, [string]		$Title				= ""
		, [string]		$Text				= ""
	)
@"
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
	<style type="text/css">
		body
		{
			font-family:Tahoma, Helvetica, sans-serif;
		}
		table
		{
			border-collapse: collapse;
			border: 1px solid black;
		}
		th
		{
			padding:3px;
			border: 1px solid gray;
			font-size:.8em;
			background:#ffffcc;
		}
		td
		{
			padding:3px;
			border: 1px solid gray;
			font-size:.8em;
		}
		a
		{
			text-decoration:none;
			background:transparent;
			color:#0000cc;
		}
		a:hover
		{
			text-decoration:none;
			background:#000000;
			color:#ffffff;
		}
	</style>
	<title>$TitleText</title>
	</head>
	<body>
"@
	if( ($WebRequest.WebServer.ApplicationMode = "development") `
		-or ($WebRequest.WebServer.ApplicationMode = "debug") )
	{
@"
		ApplicationMode = <b>$( $WebRequest.WebServer.ApplicationMode )</b><br />
		Timestamp = <b>$( Get-Date )</b><br />
		Url = <b>$( $WebRequest.ResourceName )</b><br />
		Query = $( $WebRequest.Arguments.Count ) parameter(s)<br />
		$( $WebRequest.Arguments.Keys | foreach { $_ + '=' + $WebRequest.Arguments.Item( $_ ) + '<br />' } )
		<hr>
"@
	}
@"
		$Text
"@
	return
}


#--------------------------------------------------------------------
Function Get-HtmlFooter
{
	param
	(
		  [psobject]	$WebRequest			= $( throw "WebRequest is a required parameter." )
		, [string]		$Text				= ""
	)
@"
		$Text
	</body>
	</html>
"@
	return
}


#--------------------------------------------------------------------
Function Get-HtmlNavigationMenu
{
	param
	(
		  [psobject]	$WebRequest			= $( throw "WebRequest is a required parameter." )
		, [string]		$Text				= "Navigation"
	)
	[string[]] $PathNames = $WebRequest.ResourceName.Split( "\" )
	[string] $url = $WebRequest.Protocol + "://" + $WebRequest.WebServer.ServerAddress
	[string] $html = ""
	[string] $name = ""

@"
	<div id=""site_navigation_menu"">
		<b>$Text</b>
		<table>
			<tr>
				<td>[ <a href="$url">home</a> ]</td>
"@

	foreach( $name in $PathNames )
	{
		if( $name -ne "" )
		{
			$url += "/" + $name
@"
				<td>[ <a href="$url">$name</a> ]</td>
"@
		}
	}

@"
			</tr>
		</table>
	</div>
"@
	return
}


